package com.woniuxy.credit_loans.product_liu.controller;

import com.woniuxy.credit_loans.entity.ProductRecord;
import com.woniuxy.credit_loans.product_liu.service.ProductRecordService;
import com.woniuxy.credit_loans.product_liu.vo.ProductRecordVo;
import com.woniuxy.credit_loans.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "产品审批记录的相关接口")
@RestController
@RequestMapping("/productRecords")
public class productRecordController {
    @Autowired
    private ProductRecordService productRecordService;

    @ApiOperation(value = "查询所有的产品审批信息")
    @GetMapping("")
    public Result selectAllRecords(){
        List<ProductRecordVo> productRecordVos = productRecordService.selectAllRecords();
        return Result.ok().data("productRecords",productRecordVos);
    }

    @ApiImplicitParam(name = "productrecordId",value = "产品审批表中的序号",paramType = "path",required = true)
    @DeleteMapping("{id}")
    public Result updateById(@PathVariable int id){
        ProductRecord productRecord = new ProductRecord();
        productRecord.setProductrecordId(id);
        productRecord.setProductrecordBy1("2");
        int i = productRecordService.updateByPrimaryKeySelective(productRecord);
        if(i > 0){
            return Result.ok();
        }else{
            return Result.error();
        }
    }
}
